package com.hacettepe.yemekhane;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;

import android.util.Log;

public class saveLoad {

	public void savingArrayList(ArrayList<TekYemek> myArrayList) {
		try {
			ObjectOutputStream oos = new ObjectOutputStream(
					new FileOutputStream(
							new File(
									"data/data/com.hacettepe.yemekhane/yemeklistesi.txt")));
			oos.writeObject(myArrayList);
			oos.flush();
			oos.close();
		} catch (Exception ex) {
			Log.v("Yemekhane ", ex.getMessage());
			ex.printStackTrace();
		}

	}

	@SuppressWarnings("unchecked")
	public ArrayList<TekYemek> loadingArrayList() {
		try {
			@SuppressWarnings("resource")
			ObjectInputStream ois = new ObjectInputStream(new FileInputStream(
					"data/data/com.hacettepe.yemekhane/yemeklistesi.txt"));
			Object o = ois.readObject();
			return (ArrayList<TekYemek>) o;
		} catch (Exception ex) {
			Log.v("Address Book", ex.getMessage());
			ex.printStackTrace();
		}
		return null;

	}
}
